<?php



require "../model/loginmodel.php";

class logincontrol{
	
	private $model;//业务模型
	//private $action;
	
	
	
	public function __construct(){
		$this->model=new loginmodel();
		
	}
	

	public function load($view=null){
		
		
		if(empty($view))
		{
			
			header("location:{$this->view}");
		}
		else{
			header("location:{$view}");
		}
		
	}

	/*
	 *
	*
	*/
	public function doAction($action){
		
		
		
		if($action=='login'){
			$this->loginaction();
		}
// 		else{
// 			$this->load();
// 		}
		
	}
	
	public function loginaction(){
		$userid=$_POST['userid'];
		$password=$_POST['password'];
		
		//echo 111;
		$user=$this->model->logincheck($userid, $password);
		
		if($user){
			
			session_start();
			$_SESSION['user']=$user;
// 			$this->load("./index.php?con=main");
		
			$this->load("../view/main.php");
				
		}
		else{
			session_start();
			$_SESSION['info']="用户名或密码不正确";
			//echo $_SESSION['info'];
// 			$this->load("./index.php?con=login");
			
			$this->load("../view/login.php");
				
		}
	}
	
	
}

	
?>